package cn.ibizlab.plm.testmgmt.testsuite

import java.util.List
import org.springframework.data.domain.Page

import cn.ibizlab.plm.testmgmt.testsuite.dto.*

import net.ibizsys.central.util.annotation.DEDataSet
import net.ibizsys.central.util.annotation.DEAction
import cn.ibizlab.central.plugin.groovy.dataentity.*

/**
 * 实体[TEST_SUITE]运行时对象
 * 此代码用户功能扩展代码
 *
 */
class TestSuite extends GroovyDynaDataEntityRuntime<TestSuite,TestSuiteDTO,TestSuiteFilterDTO> {

    public static final String ACTION_MOVE_ORDER = "move_order"
    public static final String DATASET_DEFAULT = "DEFAULT"
    public static final String DATASET_CUR_TEST_SUITE = "cur_test_suite"
    public static final String DATASET_NO_PARENT = "no_parent"
    public static final String DATASET_NORMAL = "normal"
    public static final String DATASET_ROOT = "root"
    private static TestSuite _instance
    void setInstance(TestSuite instance) {
        _instance = instance
    }
    static TestSuite getInstance() {
        return _instance
    }

    /**
     * 行为：Create 实际功能
     * @param dto
     * @throws Throwable
     */
    @DEAction(ACTION_CREATE)
    TestSuiteDTO create(TestSuiteDTO dto) throws Throwable {
        return this.execute(ACTION_CREATE, dto, TestSuiteDTO.class)
    }

    /**
     * 行为：Update 实际功能
     * @param dto
     * @throws Throwable
     */
    @DEAction(ACTION_UPDATE)
    TestSuiteDTO update(TestSuiteDTO dto) throws Throwable {
        return this.execute(ACTION_UPDATE, dto, TestSuiteDTO.class)
    }

    /**
     * 行为：Remove 实际功能
     * @param keys
     * @throws Throwable
     */
    @DEAction(ACTION_REMOVE)
    void remove(String key) throws Throwable {
        this.execute(ACTION_REMOVE, key, Void.class)
    }

    /**
     * 行为：Get 实际功能
     * @param key
     * @throws Throwable
     */
    @DEAction(ACTION_GET)
    TestSuiteDTO get(String key) throws Throwable {
        return this.execute(ACTION_GET, key, TestSuiteDTO.class)
    }

    /**
     * 行为：GetDraft 实际功能
     * @param dto
     * @throws Throwable
     */
    @DEAction(ACTION_GETDRAFT)
    TestSuiteDTO getDraft(TestSuiteDTO dto) throws Throwable {
        return this.execute(ACTION_GETDRAFT, dto, TestSuiteDTO.class)
    }

    /**
     * 行为：CheckKey 实际功能
     * @param dto
     * @throws Throwable
     */
    @DEAction(ACTION_CHECKKEY)
    int checkKey(TestSuiteDTO dto) throws Throwable {
        return super.checkKeyState(dto)
    }

    /**
     * 行为：Save 实际功能
     * @param dto
     * @throws Throwable
     */
    @DEAction(ACTION_SAVE)
    TestSuiteDTO save(TestSuiteDTO dto) throws Throwable {
        return this.execute(ACTION_SAVE, dto, TestSuiteDTO.class)
    }

    /**
     * 行为：移动需求 实际功能
     * @param dto
     * @throws Throwable
     */
    @DEAction(ACTION_MOVE_ORDER)
    def moveOrder(TestSuiteDTO dto) throws Throwable {
        return this.executeForList(ACTION_MOVE_ORDER, dto, TestSuiteDTO.class)
    }

    /**
     * 数据集：数据集 实际功能
     * @param dto
     * @throws Throwable
     */
    @DEDataSet(DATASET_DEFAULT)
    Page<TestSuiteDTO> fetchDefault(TestSuiteFilterDTO context) throws Throwable {
        return this.fetch(DATASET_DEFAULT, context, TestSuiteDTO.class)
    }

    /**
     * 数据集：当前测试库用例模块 实际功能
     * @param dto
     * @throws Throwable
     */
    @DEDataSet(DATASET_CUR_TEST_SUITE)
    Page<TestSuiteDTO> fetchCurTestSuite(TestSuiteFilterDTO context) throws Throwable {
        return this.fetch(DATASET_CUR_TEST_SUITE, context, TestSuiteDTO.class)
    }

    /**
     * 数据集：无父类 实际功能
     * @param dto
     * @throws Throwable
     */
    @DEDataSet(DATASET_NO_PARENT)
    Page<TestSuiteDTO> fetchNoParent(TestSuiteFilterDTO context) throws Throwable {
        return this.fetch(DATASET_NO_PARENT, context, TestSuiteDTO.class)
    }

    /**
     * 数据集：正常 实际功能
     * @param dto
     * @throws Throwable
     */
    @DEDataSet(DATASET_NORMAL)
    Page<TestSuiteDTO> fetchNormal(TestSuiteFilterDTO context) throws Throwable {
        return this.fetch(DATASET_NORMAL, context, TestSuiteDTO.class)
    }

    /**
     * 数据集：顶级模块 实际功能
     * @param dto
     * @throws Throwable
     */
    @DEDataSet(DATASET_ROOT)
    Page<TestSuiteDTO> fetchRoot(TestSuiteFilterDTO context) throws Throwable {
        return this.fetch(DATASET_ROOT, context, TestSuiteDTO.class)
    }

}